package branch.feature.debug_log

import android.app.Application
import android.content.Context
import android.content.pm.ProviderInfo
import java.lang.reflect.Method

// todo: fix this code
class LogcatEntryApp : Application() {
    override fun onCreate() {
        super.onCreate()
        try {
            val logcatProviderClass = Class.forName("com.hjq.logcat.LogcatProvider")
            val logcatProvider = logcatProviderClass.newInstance()
            val attachInfoMethod: Method = logcatProviderClass.getMethod(
                "attachInfo",
                Context::class.java,
                ProviderInfo::class.java
            )
            attachInfoMethod.setAccessible(true)
            attachInfoMethod.invoke(logcatProvider, this, null)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}